<template>
  <div>
    <van-nav-bar
        title="修改校园卡号"
        right-text="保存"
        @click-right="onClickRight"
    />
    <van-field
        v-model="user.cardNumber"
        label="校园卡号"
        placeholder="请输入校园卡号" />
  </div>

</template>

<script>
import {getUserById, updateUser} from "@/api/user";
import {Toast} from "vant";

export default {
  name: "ModifyCardNumber",
  data() {
    return {
      user: {
        username: 'dgdg',
        userType: 1,
        name: 'dsd'
      }
    }
  },
  created() {
    this.getCurrentUser()
  },
  methods: {
    getCurrentUser() {
      getUserById(1).then((response) => {
        this.user = response.data.data;
      })
    },
    onClickRight() {
      updateUser({
        'cardNumber': this.user.cardNumber,
        'createTime': this.user.createTime,
        'email': this.user.email,
        'id': this.user.id,
        'name':this.user.name,
        'password': this.user.password,
        'phone': this.user.phone,
        'userStatus':this.user.userStatus,
        'userType':this.user.userType,
        'username':this.user.username,
      }).then((response) => {
        if (response.data.code === 200) {
          Toast('修改成功');
        } else {
          Toast('修改失败');
        }
      })
    },
  }
}
</script>

<style scoped>

</style>